package com.centerm.bluetooth.lklcommon.controller;

import android.content.Context;
import android.support.annotation.NonNull;

import com.centerm.bluetooth.core.controller.BaseController;
import com.centerm.bluetooth.ibridge.BluetoothIBridgeDevice;
import com.centerm.bluetooth.lklcommon.Command;
import com.centerm.bluetooth.lklcommon.listener.ITerminalListener;
import com.centerm.bluetooth.model.Respond;
import com.centerm.util.HexUtil;

import java.io.IOException;

/**
 * Created by linwenhui on 2017/6/8.
 */

public class TerminalController extends BaseController<ITerminalListener> {

    public TerminalController(@NonNull Context context) {
        super(context);
    }

    public synchronized boolean onReset() throws IOException {
        return send(Command.RESET, null);
    }

    @Override
    public synchronized void onDataReceived(BluetoothIBridgeDevice device, Respond respond) {
        super.onDataReceived(device, respond);
        if (Command.RESET_STRING.equals(HexUtil.byte2HexStr(respond.getCmd()))) {
            if (baseListener != null)
                baseListener.onResetSuc();
        }
    }
}
